<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>库存盘点</title>
<link rel="stylesheet" type="text/css" href="../css/default.css">
<link rel="stylesheet" type="text/css" href="../js/jquery-easyui-1.3.5/themes/gray/easyui.css">
<link rel="stylesheet" type="text/css" href="../js/jquery-easyui-1.3.5/themes/icon.css" />
<script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../js/extends.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script LANGUAGE="javascript">




    function AutomateExcel() {

        var elTable = document.getElementById("tt"); //table1改成你的tableID

        var oRangeRef = document.body.createTextRange();

        oRangeRef.moveToElementText(elTable);

        oRangeRef.execCommand("Copy");

        try {
            var appExcel = new ActiveXObject("Excel.Application");
        } catch (e) {
            alert("无法调用Office对象，请确保您的机器已安装了Office并已将本系统的站点名加入到IE的信任站点列表中！");
            return;
        }

        appExcel.Visible = true;

        appExcel.Workbooks.Add().Worksheets.Item(1).Paste();

        appExcel = null;

    }
$(function(){
	$("#tt").datagrid({
		height:$("#body").height()-$('#search_area').height()-5,
		width:$("#body").width(),
		idField:'userId',
		//data: data,
		url:"datagrid.json",  
		singleSelect:true, 
		nowrap:true,
		fitColumns:true,
		rownumbers:true,
		showPageList:false,
		columns:[[
			{field:'zcid',title:'资产编号',width:100,halign:"center", align:"left"},
			{field:'name',title:'盘点人',width:100,halign:"center", align:"left"},
			{field:'kcsl',title:'库存数量',width:100,halign:"center", align:"left"},
			{field:'zcmc',title:'资产名称',width:100,halign:"center", align:"left"}
		]],
		toolbar:'#tt_btn',  
        pagination:true,
		onDblClickRow:function(rowIndex, rowData){
			viewDetail(rowData.userId);
		}
	});
})

function viewDetail(date, id){
	//var rowIndex = $('#tt').datagrid('getRowIndex', row);
	//var username=$('#tt').rowIndex.userName;
	
 var row = $('#tt').datagrid('getSelected');
 var zcid;
 var name;
 var kcsl;
 var zcmc;
 if (row) {
          zcid=row.zcid;
          name=row.name;
          zcmc=row.zcmc;
          kcsl=row.kcsl;          
  }

	//var username=$('#tt').currentColumn.rowIndex.userName;
	$parent.messager.alert("提示",zcid+","+name+","+zcmc+"'"+kcsl, "info");
}

//监听窗口大小变化
window.onresize = function(){
	setTimeout(domresize,300);
};
//改变表格宽高
function domresize(){
	$('#tt').datagrid('resize',{  
		height:$("#body").height()-$('#search_area').height()-5,
		width:$("#body").width()
	});
}
</script>
</head>
<body class="easyui-layout" >
<div id="body" region="center" > 
  <!-- 查询条件区域 -->
  <div id="search_area" >
    <div id="conditon">
    	    <div id="conditon">      
    	<table border="0">
        <tr>
          <td>资产编号：</td>
          <td ><input  name="userName1" id="userName1"   /></td>
          <td>盘点人：</td>
          <td ><input  name="userName" id="userName"   /></td>
          <td>&nbsp;库存数量：</td>
          <td><input  name="sex" id="sex"  /></td>
          <td>&nbsp;资产名称：</td>
          <td><input  name="department" id="department"  /></td>
          <td>
              <a  href="javascript:void(0)" class="easyui-linkbutton my-search-button" iconCls="icon-search" plain="true" onclick="alert('查询失败！')">查询</a> 
              <a  href="javascript:void(0)" class="easyui-linkbutton my-search-button" iconCls="icon-reset" plain="true" onclick="window.location.reload()">重置</a>
          </td>
        </tr>
      </table>
    </div>
      <table border="0">
        <tr>
          <td>
              <a  href="javascript:void(0)" class="easyui-linkbutton my-search-button" iconCls="icon-reset" plain="true" >PDF导出</a> 
              <a  href="javascript:void(0)" class="easyui-linkbutton my-search-button" iconCls="icon-reset" plain="true" onclick="AutomateExcel()" >Excel导出</a>
              <a  href="javascript:void(0)" class="easyui-linkbutton my-search-button" iconCls="icon-reset" plain="true" >Word导出</a>
          </td>
        </tr>
      </table>
    </div>
    <span id="openOrClose"></span> 
  </div>
  <!-- 数据表格区域 -->
  <table id="tt" style="table-layout:fixed;" >
  	<tr><td>KST01</td><td>颜真卿</td><td><font>7</font></td><td>笔记本电脑</td></tr>
  	<tr><td>KST02</td><td>王安石</td><td>11</td><td>办公桌</td></tr>
  	<tr><td>KST03</td><td>王维</td><td><font>3</font></td><td>工作服</td></tr>
  	<tr><td>KST04</td><td>白居易</td><td><font>5</font></td><td>清扫车</td></tr>
  	<tr><td>KST05</td><td>杜甫</td><td>21</td><td>对讲机</td></tr>
  	<tr><td>KST06</td><td>李白</td><td>11</td><td>复印机</td></tr>
  </table>
</div>
</body>
</html>
